/**
 * (created at 2010-12-28)
 */
package qiushuo.mysqlparser.recognizer;

import java.util.HashMap;
import java.util.Map;

/**
 * @author <a href="mailto:QiuShuo1985@gmail.com">QIU Shuo</a>
 */
public class Keywords {
    private static final Keywords instance = new Keywords();

    public static Keywords getInstance() {
        return instance;
    }

    private final Map<String, SQLTokenType> keywords = new HashMap<String, SQLTokenType>(227);

    private Keywords() {
        for (SQLTokenType type : SQLTokenType.class.getEnumConstants()) {
            String name = type.name();
            if (name.startsWith("KW_")) {
                String kw = name.substring("KW_".length());
                keywords.put(kw, type);
            }
        }
    }

    /**
     * case sensitive, use upper-case
     * 
     * @return <code>null</code> if argument is not keyword
     */
    public SQLTokenType getKeywordType(String str) {
        return keywords.get(str);
    }
}
